import java.util.Scanner;
public class task4 {

	public static void main(String[] args) {

		int n , i;
		double x , lnx=0 , logx;
		
		Scanner scanner = new Scanner(System.in);
		
		System.out.print("Enter number of terms:");
		n = scanner.nextInt();
		
		if(n <=0 )
			System.out.println("Error: Invalid Input");
		else
		{
			System.out.print("Enter the value of x [0 < x < 2]: ");
			x = scanner.nextDouble();
			if(x <= 0 || x >= 2)
				System.out.println("Error: Invalid value for x");
			else
			{
				for(i=1 ; i<=n ; i++)
				{
					if(i%2 != 0)
					lnx = lnx + Math.pow((x-1),i)/i;
					else
					lnx = lnx - Math.pow((x-1),i)/i;
				}
				
				logx = Math.log(x);
				
				System.out.printf("%nThe approximate value of ln(%.4f) up to %d terms is %f%n",x,n,lnx);
				System.out.printf("The value of ln(%.4f) using the standard log function is %f",x,logx);
			}
		 }
		
		scanner.close();

	}

}
